{**************************************************************************************************}
{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); }
{ you may not use this file except in compliance with the License. You may obtain a copy of the    }
{ License at http://www.mozilla.org/MPL/                                                           }
{                                                                                                  }
{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF   }
{ ANY KIND, either express or implied. See the License for the specific language governing rights  }
{ and limitations under the License.                                                               }
{                                                                                                  }
{ The Original Code is DatabaseUtils.pas                                                           }
{                                                                                                  }
{ The Initial Developer of the Original Code is Fabrizio Vita (fabrizio.vita@itacasoft.com)        }
{**************************************************************************************************}
unit DatabaseUtils;

interface

uses classes;

function JetConnectionString: string; overload;
function JetConnectionString(filename: string): string; overload;
function CreateGuid: string;

const
   ADMIN_GUID = '00000000-0000-0000-0000-000000000001';

implementation

uses SysUtils, DB, ADODB, ConversionUtils, ActiveX;

function JetFile: string;
begin
   result := changefileext(GetModulePath, '.mdb');
end;


function JetConnectionString: string;
begin
   result := JetConnectionString(jetfile);
end;

function JetConnectionString(filename: string): string;
begin
   result := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + filename;
end;


function CreateGuid: string;
var
  ID: TGUID;
begin
  Result := '';
  if CoCreateGuid(ID) = S_OK then
    Result := GUIDToString(ID);
end;

end.
